package com.rabbit.util;

import com.rabbit.constant.ResultCodeEnum;
import com.rabbit.vo.PageResultVO;
import com.rabbit.vo.ResultVO;

/**
 * <h1>响应结果工具类</h1>
 *
 * @author zjw
 * @date 2020/08/03
 */
public class ResultGenUtil {

    public static ResultVO<Object> genSuccess() {
        return genSuccess("");
    }

    public static ResultVO<Object> genSuccess(Object data) {
        return new ResultVO<>(ResultCodeEnum.SUCCESS, data);
    }

    public static ResultVO<Object> genFail(ResultCodeEnum failEnum) {
        return genFail(failEnum, failEnum.getMessage());
    }

    public static ResultVO<Object> genFail(ResultCodeEnum failEnum, Object data) {
        return new ResultVO<>(failEnum, data);
    }

    public static ResultVO<Object> genFail(ResultCodeEnum failEnum, String message) {
        return new ResultVO<>(failEnum.getCode(), message, "");
    }

    public static ResultVO<Object> genCustom(Integer code, String message) {
        return genCustom(code, message, "");
    }

    public static ResultVO<Object> genCustom(Integer code, String message, Object data) {
        return new ResultVO<>(code, message, data);
    }

    public static PageResultVO<Object> genSuccess(Object data, Long count) {
        return new PageResultVO<>(ResultCodeEnum.SUCCESS, data, count);
    }

}
